import java.util.*;
import java.io.*;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-10-18
 * Time: 18:35
 */
//卡拉有n个字符串，有两种字符串比较顺序，一种是字典顺序比较，还有一种是字符串长度比较
    //当它是按照字典序排序的，那就输出lexicographically,按照长度就输出lengths,二者都满足就输出both,都不满足就输出none
public class Main {

    public static boolean isSortZiDian(String[] str){
        for(int i=0; i<str.length-1;i++){
            if(str[i].compareTo(str[i+1])>0){
                return false;
            }

        }
        return true;

    }
    public static boolean isSortLength(String []str){
        for(int i=0;i<str.length-1;i++){
            if(str[i].length()>str[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) throws IOException {
        //BufferedReader从字符流中读取文本并且缓存
        BufferedReader bi=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bi.readLine());//读取缓存中的字符流，并且解析
        String[] str=new String[n];
        for(int i=0;i<str.length;i++){
            str[i]= bi.readLine();
        }
        if(isSortLength(str)&&isSortZiDian(str)){
            System.out.println("both");
        }
       else if(isSortZiDian(str)){
            System.out.println("lexicographically");
        }
    else    if(isSortLength(str)){
            System.out.println("lengths");
        }
       else{
            System.out.println("none");
        }




    }
}
